package com.huawang.mdesign.model.service.constant;

import com.huawang.core.definition.mof.UMLDefinitionConstants;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 這部分到時候需要MOF提供模型的唯一标识,暂时先这边作为类型判断处理。
 */
public class UAFModelConstantURI {

    private UAFModelConstantURI() {}
    public static final Map<String, List<String>> CALL_BEHAVIOR_ACTION_BEHAVIOR_CONSTRAINT = new HashMap<>();

    public static final Map<String, List<String>> CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT = new HashMap<>();

    public static final Map<String, List<String>> BEHAVIOR_FEATURE_METHOD_CONSTRAINT = new HashMap<>();

    public static final Map<String, List<String>> CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT = new HashMap<>();

    public static final Map<String, List<String>> INFORMATION_FLOW_REALIZING_ACTIVITY_EDGE_CONSTRAINT = new HashMap<>();

    public static final Map<String, List<String>> CLASSIFIER_TO_SLOT_STEREOTYPE_CONSTRAINT = new HashMap<>();

    static {
        // 行为约束
        CALL_BEHAVIOR_ACTION_BEHAVIOR_CONSTRAINT.put(UMLDefinitionConstants.UAF_OperationalActivityAction,
                Stream.of(UMLDefinitionConstants.UAF_OperationalActivity, UAFDefinitionConstants.OPERATIONAL_ACTION).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_BEHAVIOR_CONSTRAINT.put(UMLDefinitionConstants.UAF_SecurityProcessAction,
                Stream.of(UMLDefinitionConstants.UAF_SecurityProcess).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_BEHAVIOR_CONSTRAINT.put(UMLDefinitionConstants.UAF_FunctionAction,
                Stream.of(UMLDefinitionConstants.UAF_Function, UAFDefinitionConstants.RESOURCE_ACTION).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_BEHAVIOR_CONSTRAINT.put(UMLDefinitionConstants.UAF_ServiceFunctionAction,
                Stream.of(UMLDefinitionConstants.UAF_ServiceFunction, UAFDefinitionConstants.SERVICE_ACTION).collect(Collectors.toList()));

        // 活动约束
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UMLDefinitionConstants.UAF_OperationalActivityAction,
                Stream.of(UMLDefinitionConstants.UAF_OperationalActivity).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UMLDefinitionConstants.UAF_FunctionAction,
                Stream.of(UMLDefinitionConstants.UAF_Function).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UAFDefinitionConstants.RESOURCE_ACTION,
                Stream.of(UMLDefinitionConstants.UAF_Function).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UMLDefinitionConstants.UAF_ServiceFunctionAction,
                Stream.of(UMLDefinitionConstants.UAF_ServiceFunction).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UMLDefinitionConstants.UAF_SecurityProcessAction,
                Stream.of(UMLDefinitionConstants.UAF_SecurityProcess).collect(Collectors.toList()));
        CALL_BEHAVIOR_ACTION_ACTIVITY_CONSTRAINT.put(UAFDefinitionConstants.SERVICE_ACTION,
                Stream.of(UMLDefinitionConstants.UAF_ServiceFunction).collect(Collectors.toList()));

        // 方法约束
        BEHAVIOR_FEATURE_METHOD_CONSTRAINT.put(UMLDefinitionConstants.UAF_ResourceMethod,
                Stream.of(UMLDefinitionConstants.UAF_Function).collect(Collectors.toList()));
        BEHAVIOR_FEATURE_METHOD_CONSTRAINT.put(UMLDefinitionConstants.UAF_ServiceMethod,
                Stream.of(UMLDefinitionConstants.UAF_ServiceFunction).collect(Collectors.toList()));
        BEHAVIOR_FEATURE_METHOD_CONSTRAINT.put(UMLDefinitionConstants.UAF_OperationalMethod,
                Stream.of(UMLDefinitionConstants.UAF_OperationalActivity).collect(Collectors.toList()));

        // uaf资源约束、业务约束、安全约束、战略约束
        CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT.put(UMLDefinitionConstants.UAF_OperationalConstraint,
                Stream.of(UMLDefinitionConstants.UAF_SubjectOfOperationalConstraint).collect(Collectors.toList()));
        CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT.put(UMLDefinitionConstants.UAF_ResourceConstraint,
                Stream.of(UMLDefinitionConstants.UAF_SubjectOfResourceConstraint).collect(Collectors.toList()));
        CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT.put(UMLDefinitionConstants.UAF_SecurityConstraint,
                Stream.of(UMLDefinitionConstants.UAF_SubjectOfSecurityConstraint).collect(Collectors.toList()));
        CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT.put(UMLDefinitionConstants.UAF_StrategicConstraint,
                Stream.of(UMLDefinitionConstants.UAF_SubjectOfStrategicConstraint).collect(Collectors.toList()));
        CONSTRAINT_CONSTRAINED_ELEMENT_CONSTRAINT.put(UMLDefinitionConstants.UAF_ServicePolicy,
                Stream.of(UMLDefinitionConstants.UAF_Service).collect(Collectors.toList()));

        // 实现活动路径约束
        INFORMATION_FLOW_REALIZING_ACTIVITY_EDGE_CONSTRAINT.put(UMLDefinitionConstants.UAF_OperationalExchange,
                Stream.of(UMLDefinitionConstants.UAF_OperationalActivityEdge).collect(Collectors.toList()));
        INFORMATION_FLOW_REALIZING_ACTIVITY_EDGE_CONSTRAINT.put(UMLDefinitionConstants.UAF_ResourceExchange,
                Stream.of(UMLDefinitionConstants.UAF_FunctionEdge).collect(Collectors.toList()));
        INFORMATION_FLOW_REALIZING_ACTIVITY_EDGE_CONSTRAINT.put(UMLDefinitionConstants.UAF_ServiceExchange,
                Stream.of(UMLDefinitionConstants.UAF_ServiceFunctionEdge).collect(Collectors.toList()));

        // 属性应有的插槽构造型
        CLASSIFIER_TO_SLOT_STEREOTYPE_CONSTRAINT.put(UMLDefinitionConstants.UAF_Measurement,
                Collections.singletonList(UMLDefinitionConstants.UAF_ActualMeasurement));
        CLASSIFIER_TO_SLOT_STEREOTYPE_CONSTRAINT.put(UMLDefinitionConstants.UAF_ProjectRole,
                Collections.singletonList(UMLDefinitionConstants.UAF_ActualProjectRole));
        CLASSIFIER_TO_SLOT_STEREOTYPE_CONSTRAINT.put(UMLDefinitionConstants.UAF_ResourceRole,
                Collections.singletonList(UMLDefinitionConstants.UAF_ActualResourceRole));
    }
}
